***Yearly Support Analysis***

*load yearly_support.dta file

twoway (line House_Support Year if Year>=1969, lcolor(black) lpattern(solid)) (fpfit House_Support Year if Year>=1969, lcolor(black) lpattern(dash)) (line Senate_Support Year if Year>=1969, lcolor(gray) lpattern(solid)) (fpfit Senate_Support Year if Year>=1969, lcolor(gray) lpattern(dash)), xscale(range(1968 2017)) xlabel(1968(2)2017, angle(45)) yscale(range(40 100)) ylabel(40 50 60 70 80 90 100) ytitle(Presidential Support) xtitle(Year) legend(position(6) label(1 "House (Actual)") label(2 "House (Trend)") label(3 "Senate (Actual)") label(4 "Senate (Trend)"))
*figure 1

egen sHouse_Polarization=std(House_Polarization)
egen sSenate_Polarization=std(Senate_Polarization)
egen sHouse_Cohesion_2=std(House_Cohesion_2)
egen sSenate_Cohesion_2=std(Senate_Cohesion_2)
egen sHouse_Seat_Gain=std(House_Seat_Gain)
egen sSenate_Seat_Gain=std(Senate_Seat_Gain)
egen sYear_In_Office=std(Year_In_Office)
egen sPres_Approval=std(Pres_Approval)
egen sMilitary_Casualties=std(Military_Casualties)
*standardizes the continuous variables

reg House_Support sHouse_Polarization c.sHouse_Cohesion_2##i.Dem_President House_Majority sHouse_Seat_Gain sYear_In_Office sPres_Approval sMilitary_Casualties if Year>=1969, vce(robust)
*table 1 House model
reg Senate_Support sSenate_Polarization c.sSenate_Cohesion_2##i.Dem_President Senate_Majority sSenate_Seat_Gain sYear_In_Office sPres_Approval sMilitary_Casualties if Year>=1969, vce(robust)
*table 1 Senate Model

replace Year_In_Office=1 if Year==2017
replace Dem_President=0 if Year==2017
replace Pres_Approval=38.5 if Year==2017
replace House_Majority=1 if Year==2017
replace Senate_Majority=1 if Year==2017
replace House_Support=95.94 if Year==2017
replace Senate_Support=98.9 if Year==2017
*adding 2017 data for Trump's first year

drop sHouse_Polarization-sMilitary_Casualties
egen sHouse_Polarization=std(House_Polarization)
egen sSenate_Polarization=std(Senate_Polarization)
egen sHouse_Cohesion_2=std(House_Cohesion_2)
egen sSenate_Cohesion_2=std(Senate_Cohesion_2)
egen sHouse_Seat_Gain=std(House_Seat_Gain)
egen sSenate_Seat_Gain=std(Senate_Seat_Gain)
egen sYear_In_Office=std(Year_In_Office)
egen sPres_Approval=std(Pres_Approval)
egen sMilitary_Casualties=std(Military_Casualties)
*restandardizing the continuous variables with 2017 included

reg House_Support sHouse_Polarization c.sHouse_Cohesion_2##i.Dem_President House_Majority sHouse_Seat_Gain sYear_In_Office sPres_Approval sMilitary_Casualties if Year>=1969, vce(robust)
predict House_XB, xb
predict House_STDP, stdp
gen House_Lower=House_XB-(1.96*House_STDP)
gen House_Upper=House_XB+(1.96*House_STDP)
sort Year
twoway (rcap House_Lower House_Upper Year if Year>=1969) (scatter House_Support Year if Year>=1969, mcolor(red) mfcolor(red) msymbol(circle) msize(med)) (scatter House_XB Year if Year>=1969, mcolor(black) mfcolor(black) msize(medlarge) msymbol(plus)), legend(position(6) label(1 "95% Confidence Interval") label(2 "Actual Presidential Support") label(3 "Predicted Presidential Support")) yscale(range(50 100)) ytitle(Presidential Support)  ylabel(50 60 70 80 90 100) xscale(range(1969 2017)) xlabel(1969 1973 1977 1981 1985 1989 1993 1997 2001 2005 2009 2013 2017)
*figure 2

reg Senate_Support sSenate_Polarization c.sSenate_Cohesion_2##i.Dem_President Senate_Majority sSenate_Seat_Gain sYear_In_Office sPres_Approval sMilitary_Casualties if Year>=1969, vce(robust)
predict Senate_XB, xb
predict Senate_STDP, stdp
gen Senate_Lower=Senate_XB-(1.96*Senate_STDP)
gen Senate_Upper=Senate_XB+(1.96*Senate_STDP)
sort Year
twoway (rcap Senate_Lower Senate_Upper Year if Year>=1969) (scatter Senate_Support Year if Year>=1969, mcolor(red) mfcolor(red) msymbol(circle) msize(med)) (scatter Senate_XB Year if Year>=1969, mcolor(black) mfcolor(black) msize(medlarge) msymbol(plus)), legend(position(6) label(1 "95% Confidence Interval") label(2 "Actual Presidential Support") label(3 "Predicted Presidential Support")) yscale(range(50 100)) ytitle(Presidential Support)  ylabel(50 60 70 80 90 100) xscale(range(1969 2017)) xlabel(1969 1973 1977 1981 1985 1989 1993 1997 2001 2005 2009 2013 2017)
*figure 3



***Member Support Analysis***

*clear data from memory and load member_support.dta file

heckprobit Trump_Support Conservatism Female Hispanic Mormon GOP_Vote Victory_Margin Electoral_Threat College_Pop Per_Capita_Income Manufacturing_Pop Economic_Anxiety Hispanic_Pop Black_Pop Muslim_Pop Racial_Problems Muslim_Ban More_Border More_Police Establishment_Record TPC_Freedom Cong_Leader Party_Unity Senator Terms if Nomination==0, select(Trump_Position = Conservative_Bill Establishment_Bill Cosponsors House_Bill Rules-Energy_Res Environment) vce(robust)
*table 2 model without nomination votes
heckprobit Trump_Support Conservatism Female Hispanic Mormon GOP_Vote Victory_Margin Electoral_Threat College_Pop Per_Capita_Income Manufacturing_Pop Economic_Anxiety Hispanic_Pop Black_Pop Muslim_Pop Racial_Problems Muslim_Ban More_Border More_Police Establishment_Record TPC_Freedom Cong_Leader Party_Unity Senator Terms, select(Trump_Position = Conservative_Bill Establishment_Bill House_Bill Rules-Energy_Res Environment) vce(robust)
*model 2 model with nomination votes

egen sConservatism=std(Conservatism)
egen sPer_Capita_Income=std(Per_Capita_Income)
egen sHispanic_Pop=std(Hispanic_Pop)
egen sBlack_Pop=std(Black_Pop)
egen sEstablishment_Record=std(Establishment_Record)
replace Female=((Female*-1)+1)
replace sPer_Capita_Income=(sPer_Capita_Income*-1)
replace sHispanic_Pop=(sHispanic_Pop*-1)
replace sBlack_Pop=(sBlack_Pop*-1)
*standardizing the significant variables and placing them in the same direction

heckprobit Trump_Support sEstablishment_Record Female sConservatism sPer_Capita_Income sBlack_Pop sHispanic_Pop Hispanic Mormon GOP_Vote Victory_Margin Electoral_Threat College_Pop Manufacturing_Pop Economic_Anxiety Muslim_Pop Racial_Problems Muslim_Ban More_Border More_Police TPC_Freedom Cong_Leader Party_Unity Senator Terms if Nomination==0, select(Trump_Position = Conservative_Bill Establishment_Bill Cosponsors House_Bill Rules-Energy_Res Environment) vce(robust)
margins, dydx(sEstablishment_Record Female sConservatism sPer_Capita_Income sBlack_Pop sHispanic_Pop) atmeans post cont
marginsplot, horizontal xline(0) yscale(reverse) recast(scatter) graphr(c(white)) scheme(s2mono) xtitle("Marginal Effect on Trump Support in Congress" " " "Negative Sign = Decreases Support" "Positive Sign = Increases Support") ytitle(Significant Factors) title(" ") ylabel(1 "Establishment Record" 2 "Female" 3 "Conservatism" 4 "Per Capita Income" 5 "Black Population" 6 "Hispanic Population")
*figure 4
